Passed
Push — development ( 26403f...98b3d9 )
by Vad
08:03 queued 49s
created

CitiesController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A createACity 0 10 1
A getAllCities 0 10 1
1 6
import { Body, Controller, Get, Post } from '@nestjs/common';
2 6
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
3 6
import { CitiesService } from './cities.service';
4 6
import { CreateCityDto } from './dto/create-city.dto';
5
import { CityName } from './types/city.enum';
0 ignored issues
show
introduced by
'CityName' is defined but never used.
Loading history...
6 6
import { City } from './entities/city.entity';
7
8
@ApiTags('Cities')
9
@Controller({ path: 'cities', version: '1' })
10 6
export class CitiesController {
11 3
  constructor(private readonly citiesService: CitiesService) {}
12
13
  @Get()
14
  @ApiOperation({ summary: 'Get all cities' })
15
  @ApiResponse({
16
    status: 200,
17
    description: 'List of bicycles',
18
    type: [City],
19
  })
20 6
  async getAllCities() {
21 1
    return await this.citiesService.findAll();
22
  }
23
24
  @Post('create')
25
  @ApiOperation({ summary: 'Create a new city' })
26
  @ApiResponse({
27
    status: 201,
28
    description: 'City created successfully',
29
    type: City,
30
  })
31 6
  async createACity(@Body() createCityDto: CreateCityDto) {
32 1
    return await this.citiesService.createCity(createCityDto);
33
  }
34
}
35